﻿function setValueCmbHdn(obj) {
    $get(obj.parentElement.id + "_Hidden").value = obj.value;
}

function ValidObjectCmb(obj) {
    try {
        var len = obj.value.trim().length;
        var error = "";
        if (len == 0) {
            obj.parentElement.childNodes[2].childNodes[0].className = "btn dropdown-toggle selectpicker btn-default validatorCalloutHighlight";
            for (j = 0; j < obj.attributes.length; j++) {
                if (obj.attributes[j].name == "errormessage") {
                    error = obj.attributes[j].value;
                }
            }
            obj.parentElement.title = error == "" ? "Requerido" : error;
            return false;
        }
        else {
            obj.parentElement.childNodes[2].childNodes[0].className = "btn dropdown-toggle selectpicker btn-default";
            obj.parentElement.title = "";
        }

        return true;
    }
    catch (e) {
        //alert(e.Description);
        return true;
    }
}

function ValidExpressionCmb(obj, expression) {
    if (expression.trim() == "")
        return true;
    var RegEx = new RegExp(expression);
    var valid = RegEx.test(obj.value);

    if (!valid) {
        obj.parentElement.childNodes[2].childNodes[0].className = "btn dropdown-toggle selectpicker btn-default validatorCalloutHighlight";
        return false;
    }
    else {
        obj.parentElement.childNodes[2].childNodes[0].className = "btn dropdown-toggle selectpicker btn-default";
    }

    return true;
}